export interface Refs {
    menuTree: YvanUI.CtlTree;
    btnSave: YvanUI.CtlButton;
    billDate: YvanUI.CtlDatePicker;
}

function componentRenderFilter(vjson: any): boolean {
    if (_.has(vjson, 'requirePromission')) {
        if (_.indexOf(vjson.requirePromission, '2') >= 0) {
            // 不显示权限中包含2 的
            return false;
        }
    }
    return true;
}

YvanUI.componentRenderFilter = componentRenderFilter;

@YvanUI.BizModule()
export default class ExamplePromission extends YvanUI.BaseModule<ExamplePromission, Refs, void> {
    viewResolver(): any {
        return {
            rows: [
                {
                    cols: [
                        { view: 'text', label: '字段11', requirePromission: 'F11' },
                        { view: 'text', label: '字段12', requirePromission: 'F12' },
                        { view: 'text', label: '字段13', requirePromission: 'F13' }
                    ],
                },
                {
                    cols: [
                        { view: 'text', label: '字段21', requirePromission: 'F31' },
                        { view: 'text', label: '字段22', requirePromission: 'F31' },
                        { view: 'text', label: '字段23', requirePromission: 'F31' },
                    ]
                },
                {
                    cols: [
                        {
                            view: 'viewer',
                            value: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597313858321&di=f06fa09b6d3c9361d3359e1ed5d39ccf&imgtype=0&src=http%3A%2F%2Fg3.hexunimg.cn%2F2013-08-05%2F156782035.jpg',
                            width: 50,
                        },
                        { view: 'text', label: '字段22', requirePromission: 'F31' },
                        { view: 'text', label: '字段23', requirePromission: 'F31' },
                    ]
                },
                {
                    view: 'viewer',
                    value: '',
                    width: 200,
                },
                {
                    view: 'viewer',
                    value: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1597312947406&di=d8e8413895b7a34a804c558b749105ab&imgtype=0&src=http%3A%2F%2Fshanxiji.sinaimg.cn%2F2013%2F0623%2FU9665P1335DT20130623092909.jpg',
                    width: 200,
                },
                {
                    view: 'viewer',
                },
                {
                    requirePromission: 'F21',
                    hiddenPlaceholder: {},
                    cols: [
                        { view: 'tree' },
                    ]
                }
            ]
        }
    }

    onLoad() {

    }
}